package com.xs.designs.duty_chain.chain;

import com.xs.designs.duty_chain.pojo.ProductDto;

public abstract class IHandler<T,R> {
    public IHandler<T,R> nextHandler;

    public void setNextHandler(IHandler<T,R> nextHandler) {
        this.nextHandler = nextHandler;
    }

    public boolean hasNext() {
        return this.nextHandler != null;
    }
    /**
     * 处理责任链逻辑， 执行下个环节
     */
    public R handle(T t){
        if(hasNext()){
           return nextHandler.handle(t);
        }
        return  null;
    };

}